<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>ckplayer</title>
		
		<style type="text/css">body{margin:0;padding:0px;font-family:"Microsoft YaHei",YaHei,"微软雅黑",SimHei,"黑体";font-size:14px}</style>

	</head>

	<body>
		<script type="text/javascript" src="ckplayer/ckplayer.js"></script>
		<div id="video" style="width: 100%; height: 400px;"></div>
		<script type="text/javascript">
			console.log(ckplayerConfig());
			var videoObject = {
				container: '#video', //容器的ID或className
				variable: 'player',//播放函数名称
				poster:'material/poster.jpg',//封面图片
				autoplay: true,
				loaded: 'loadedHandler',
				mobileCkControls:false,
				autoLoad:true,
				live:true,
				video: [//视频地址列表形式
					['http://dy.jsyunbf.com/20170914/3fMIUCOf/index.m3u8', 'video/m3u8', '中文标清', 0]
				]
			};
			var player = new ckplayer(videoObject);
			function loadedHandler() {
				player.changeControlBarShow(false);
				player.videoProportion();
				//changeVideo('http://192.168.31.222:56565/');
				player.addListener('clickEvent', clickEventHandler);
			};

			function changeVideo(videoUrl) {
				if(player == null) {
					return;
				}
				//判断是需要重新加载播放器还是直接换新地址

				if(player.playerType == 'html5video') {
					if(player.getFileExt(videoUrl) == '.flv' || player.getFileExt(videoUrl) == '.m3u8' || player.getFileExt(videoUrl) == '.f4v' || videoUrl.substr(0, 4) == 'rtmp') {
						player.removeChild();

						player = null;
						player = new ckplayer();
						player.embed(videoObject);
					} else {
						player.newVideo(videoObject);
					}
				} else {
					if(player.getFileExt(videoUrl) == '.mp4' || player.getFileExt(videoUrl) == '.webm' || player.getFileExt(videoUrl) == '.ogg') {
						player = null;
						player = new ckplayer();
						player.embed(videoObject);
					} else {
						player.newVideo(videoObject);
					}
				}
			};
			function clickEventHandler(eve){
				changeVideo('http://192.168.31.222:56565/');
				console.log('23232332');
			}
			
		</script>
		<div id="aa"></div>
	</body>

</html>